package com.zmn.oms.common.enums;

import com.zmn.consts.DictModel;

import java.util.ArrayList;
import java.util.List;

/**
 * 类描述：订单评价枚举
 *
 * @author yangshuangping
 * @since 2022/07/04 15:09
 */
public enum OrderAcceptanceEnum {
    /**
     * 非常满意
     */
    FCMY(1, "非常满意"),
    /**
     * 一般满意
     */
    YBMY(2, "一般满意"),
    /**
     * 较为不满意
     */
    JWMY(3, "较为不满意"),
    /**
     * 非常不满意
     */
    FCBMY(4, "非常不满意");

    private Integer code;
    private String text;

    OrderAcceptanceEnum(Integer code, String text) {
        this.code = code;
        this.text = text;
    }

    /**
     * 订单验收评价枚举
     *
     * @return List<DictModel>
     */
    public static List<DictModel> getOrderAcceptanceList() {
        List<DictModel> items = new ArrayList<>(4);
        items.add(new DictModel(FCMY.code, FCMY.text));
        items.add(new DictModel(YBMY.code, YBMY.text));
        items.add(new DictModel(JWMY.code, JWMY.text));
        items.add(new DictModel(FCBMY.code, FCBMY.text));
        return items;
    }

    public Integer getCode() {
        return code;
    }

    public String getText() {
        return text;
    }

    public static OrderAcceptanceEnum of(Integer code) {
        if (code == null) {
            return null;
        }
        switch (code) {
            case 1:
                return FCMY;
            case 2:
                return YBMY;
            case 3:
                return JWMY;
            case 4:
                return FCBMY;
            default:
                return null;
        }
    }

    public static String getText(Integer code) {
        OrderAcceptanceEnum of = of(code);
        return of == null ? null : of.getText();
    }
}
